package GetClass;

public class GetClassTest {
    public static void main(String[] args) {

        Animal[] as =new Animal[]{new Animal.Dog(),new Cat()};
    if(as[0]instanceof Animal.Dog){

    }else if(as[0]instanceof  Cat){

    }
    //判断数组俩个对象的真实类型是否相同
     /**   if(as[0]instanceof Dog){
            if(as[1]instanceof Dog){
                System.out.println("俩个都是狗对象");
            }
        }
        if(as[0]instanceof Cat){
            if(as[1]instanceof Cat){
                System.out.println("俩个都是狗对象");
            }
        }
      */
        System.out.println(as[0].getClass());//获得真实类型
        System.out.println(as[1].getClass());
        System.out.println(as[0].getClass()==as[1].getClass());//faulse
    }
}
class Animal{
    static class  Dog extends  Animal{

    }
}
class Cat extends  Animal{

}